// 引入 Dialog

import Dialog from '@vant/weapp/dialog/dialog';
import { listSelf } from "@/api/check.js"
Page({
  data: {
    activeNames: ['1'],
    checked: true,
    checkAssetList: []
  },
  onChange(event) {
    this.setData({
      activeNames: event.detail,
    });
  },
  onClose(event) {
    Dialog.alert({
      title: '标题',
      message: '弹窗内容',
    }).then(() => {
      // on close
    });
    const { position, instance } = event.detail;
    switch (position) {
      case 'left':
      case 'cell':
        instance.close();
        break;
      case 'right':
        Dialog.confirm({
          message: '确定删除吗？',
        }).then(() => {
          instance.close();
        });
        break;
    }
  },
  onCheckChange(event) {
    this.setData({
      checked: event.detail,
    });
  },
  getCheckList() {
    listSelf(0).then(res=>{
      
      console.log("checkAssetList", res);
      this.setData({
        checkAssetList: res.data
      });
    })
  },
  onClickDetail(event) {
    const id = event.currentTarget.dataset.id;
    console.log('点击了资产id:', id);

    // 根据类型跳转到不同页面或执行其他操作
    wx.navigateTo({
      url: `/pages/check/detail?id=${id}`,
    });
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getCheckList();
  },

});